<?php

/**
 * AbetProject filter form base class.
 *
 * @package    sfproject
 * @subpackage filter
 * @author     Your name here
 */
abstract class BaseAbetProjectFormFilter extends BaseFormFilterPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'proj_title'             => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'proj_desc'              => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'proj_ctgry'             => new sfWidgetFormFilterInput(),
      'proj_degree'            => new sfWidgetFormFilterInput(),
      'assign_team'            => new sfWidgetFormPropelChoice(array('model' => 'AbetTeam', 'add_empty' => true, 'key_method' => 'getTeamName')),
      'created_at'             => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'updated_at'             => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'abet_project_list_list' => new sfWidgetFormPropelChoice(array('model' => 'AbetTeam', 'add_empty' => true)),
    ));

    $this->setValidators(array(
      'proj_title'             => new sfValidatorPass(array('required' => false)),
      'proj_desc'              => new sfValidatorPass(array('required' => false)),
      'proj_ctgry'             => new sfValidatorPass(array('required' => false)),
      'proj_degree'            => new sfValidatorPass(array('required' => false)),
      'assign_team'            => new sfValidatorPropelChoice(array('required' => false, 'model' => 'AbetTeam', 'column' => 'team_name')),
      'created_at'             => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'updated_at'             => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'abet_project_list_list' => new sfValidatorPropelChoice(array('model' => 'AbetTeam', 'required' => false)),
    ));

    $this->widgetSchema->setNameFormat('abet_project_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function addAbetProjectListListColumnCriteria(Criteria $criteria, $field, $values)
  {
    if (!is_array($values))
    {
      $values = array($values);
    }

    if (!count($values))
    {
      return;
    }

    $criteria->addJoin(AbetProjectListPeer::PROJ_ID, AbetProjectPeer::INS_CODE);

    $value = array_pop($values);
    $criterion = $criteria->getNewCriterion(AbetProjectListPeer::TEAM_ID, $value);

    foreach ($values as $value)
    {
      $criterion->addOr($criteria->getNewCriterion(AbetProjectListPeer::TEAM_ID, $value));
    }

    $criteria->add($criterion);
  }

  public function getModelName()
  {
    return 'AbetProject';
  }

  public function getFields()
  {
    return array(
      'ins_code'               => 'ForeignKey',
      'proj_id'                => 'Text',
      'proj_title'             => 'Text',
      'proj_desc'              => 'Text',
      'proj_ctgry'             => 'Text',
      'proj_degree'            => 'Text',
      'assign_team'            => 'ForeignKey',
      'created_at'             => 'Date',
      'updated_at'             => 'Date',
      'abet_project_list_list' => 'ManyKey',
    );
  }
}
